import Taro, { Component } from '@tarojs/taro'
import { View, Image, Text } from '@tarojs/components'

import Public from './../../api/public'
import './loading.less'
import allRequest from './../../api/allRequest';
import { DataLoading } from './../../component/index'

class Index extends Component {

    config = {
        navigationStyle: "custom",
        enablePullDownRefresh: false,
        navigationBarTitleText: ' ',
    }

    componentWillReceiveProps(nextProps) {
        console.log(this.props, nextProps)
    }

    componentDidMount() {
        Public.Person().then((result) => {
            if (Taro.getEnv() === Taro.ENV_TYPE.WEAPP) {
                //版本处理
                if (result.version.version_compare == 1) {
                    Taro.redirectTo({
                        url: '/subPackages/examine/main/main'
                    })
                } else {
                    if (Taro.getStorageSync('situation')) {
                        Taro.redirectTo({
                            url: `/pages/${Taro.getStorageSync('situation')}/index/index`
                        })
                    } else {
                        // Taro.redirectTo({
                        //     url: `/pages/consumer/index/index`
                        // })
                        Taro.redirectTo({
                            url: `/subPackages/examine/identity/identity`
                        })
                    }
                }
            } else {
                if (Taro.getStorageSync('situation')) {
                    Taro.redirectTo({
                        url: `/pages/${Taro.getStorageSync('situation')}/index/index`
                    })
                } else {
                    // Taro.redirectTo({
                    //     url: `/pages/consumer/index/index`
                    // })
                    Taro.redirectTo({
                        url: `/subPackages/examine/identity/identity`
                    })
                }
            }

        }).catch((err) => {
            console.log(err)
        });
    }

    componentWillUnmount() { }

    componentDidShow() { }

    componentDidHide() { }

    render() {
        return (
            <View className='loading'>
                {/* <Image src='https://file.open.banchengyun.com/2019/05/24/155869370541704.gif' className='loadImg'></Image> */}
                {/* <View className='content'>
                    <Image className='img' src='https://file.open.banchengyun.com/2019/05/23/155857644839223.gif'></Image>
                    <View className='loadText'>加载中~</View>
                </View> */}
                <DataLoading></DataLoading>
            </View>
        )
    }
}

export default Index
